package com.sdd.sg.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

/**
 * ClassName: DataConvertUtil
 * Description: 数据转换
 * date: 2020/7/6
 *
 * @author xugaojun
 */
@Slf4j
public class DataConvertUtil {

    public static <T> T convertOne(Object source, Class<T> target) {
        if (null == source) {
            return null;
        }

        T t = null;

        try {

            t = target.newInstance();
            BeanUtils.copyProperties(source, t);
        } catch (Exception e) {
            log.error("数据转换错误");
        }

        return t;
    }

}
